<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="物料名称" prop="fdItemName">
        <el-input
          v-model="queryParams.fdItemName"
          placeholder="请输入物料名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料编号" prop="fdItemCode">
        <el-input
          v-model="queryParams.fdItemCode"
          placeholder="请输入物料编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料子编号" prop="fdWlzbh">
        <el-input
          v-model="queryParams.fdWlzbh"
          placeholder="请输入物料子编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料识别码" prop="fdItemIdentifyCode">
        <el-input
          v-model="queryParams.fdItemIdentifyCode"
          placeholder="请输入物料识别码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格型号" prop="fdSpec">
        <el-input
          v-model="queryParams.fdSpec"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料分类编码" prop="fdClassId">
        <el-input
          v-model="queryParams.fdClassId"
          placeholder="请输入物料分类编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料分类名称" prop="fdClassName">
        <el-input
          v-model="queryParams.fdClassName"
          placeholder="请输入物料分类名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料大类编码" prop="fdClassBigId">
        <el-input
          v-model="queryParams.fdClassBigId"
          placeholder="请输入物料大类编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料大类名称" prop="fdClassBigName">
        <el-input
          v-model="queryParams.fdClassBigName"
          placeholder="请输入物料大类名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商编码" prop="fdSupplyId">
        <el-input
          v-model="queryParams.fdSupplyId"
          placeholder="请输入供应商编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商名称" prop="fdSupplyName">
        <el-input
          v-model="queryParams.fdSupplyName"
          placeholder="请输入供应商名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['ys:iteminfo:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['ys:iteminfo:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['ys:iteminfo:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['ys:iteminfo:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="info"
            plain
            icon="el-icon-upload2"
            size="mini"
            @click="handleImport"
        >导入</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="iteminfoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键编码" align="center" prop="id" />
      <el-table-column label="序号" align="center" prop="fdSerialNum" />
      <el-table-column label="组织代码" align="center" prop="fdOrganizationCode" />
      <el-table-column label="组织名称" align="center" prop="fdOrganizationName" />
      <el-table-column label="组织分类" align="center" prop="fdOrganizationCategory" />
      <el-table-column label="组织层级" align="center" prop="fdOrganizationLevel" />
      <el-table-column label="物料名称" align="center" prop="fdItemName" />
      <el-table-column label="物料编号" align="center" prop="fdItemCode" />
      <el-table-column label="物料子编号" align="center" prop="fdWlzbh" />
      <el-table-column label="物料识别码" align="center" prop="fdItemIdentifyCode" />
      <el-table-column label="物料单位" align="center" prop="fdUnit" />
      <el-table-column label="规格型号" align="center" prop="fdSpec" />
      <el-table-column label="条码号" align="center" prop="fdBarcode" />
      <el-table-column label="物料分类编码" align="center" prop="fdClassId" />
      <el-table-column label="物料分类名称" align="center" prop="fdClassName" />
      <el-table-column label="物料大类编码" align="center" prop="fdClassBigId" />
      <el-table-column label="物料大类名称" align="center" prop="fdClassBigName" />
      <el-table-column label="供应商编码" align="center" prop="fdSupplyId" />
      <el-table-column label="供应商名称" align="center" prop="fdSupplyName" />
      <el-table-column label="供应商类别" align="center" prop="fdSupplyType" />
      <el-table-column label="供应商简称" align="center" prop="fdSupplyJc" />
      <el-table-column label="存储期" align="center" prop="fdCunchudate" />
      <el-table-column label="保质期" align="center" prop="fdProductiondate" />
      <el-table-column label="图片地址" align="center" prop="fdUrl" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.fdUrl" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="预警上线" align="center" prop="fdUpLine" />
      <el-table-column label="预警下线" align="center" prop="fdDownLine" />
      <el-table-column label="中间值" align="center" prop="fdMiddleLine" />
      <el-table-column label="尺寸" align="center" prop="fdSize" />
      <el-table-column label="单重" align="center" prop="fdSingleWeight" />
      <el-table-column label="使用状态" align="center" prop="fdUseState" />
      <el-table-column label="颜色" align="center" prop="fdColor" />
      <el-table-column label="花纹" align="center" prop="fdFigure" />
      <el-table-column label="材质" align="center" prop="fdCaizhi" />
      <el-table-column label="包装数量" align="center" prop="fdPackingNum" />
      <el-table-column label="包装方式" align="center" prop="fdBaozhuangType" />
      <el-table-column label="物料状态" align="center" prop="fdItemState" />
      <el-table-column label="组织机构" align="center" prop="fdDeptId" />
      <el-table-column label="托管状态" align="center" prop="fdTgState" />
      <el-table-column label="成本价" align="center" prop="fdCostPrice" />
      <el-table-column label="计划价" align="center" prop="fdJhPrice" />
      <el-table-column label="合同价" align="center" prop="fdHtPrice" />
      <el-table-column label="发票价" align="center" prop="fdFpPrice" />
      <el-table-column label="结算价" align="center" prop="fdJsPrice" />
      <el-table-column label="生产周期" align="center" prop="fdProductionCycle" />
      <el-table-column label="供货周期" align="center" prop="fdSupplyCycle" />
      <el-table-column label="供货份额" align="center" prop="fdDeliveryFe" />
      <el-table-column label="份额调整比例" align="center" prop="fdAdjustRate" />
      <el-table-column label="份额调整日期" align="center" prop="fdAdjustDate" width="180"/>
      <el-table-column label="月订单数量" align="center" prop="fdYddNum" />
      <el-table-column label="月完成数量" align="center" prop="fdYwcNum" />
      <el-table-column label="月度供货未完成比率" align="center" prop="fdYghwcbl" />
      <el-table-column label="备注" align="center" prop="fdRemark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['ys:iteminfo:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['ys:iteminfo:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改物料信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="序号" prop="fdSerialNum">
              <el-input v-model="form.fdSerialNum" placeholder="请输入序号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="组织代码" prop="fdOrganizationCode">
              <el-input v-model="form.fdOrganizationCode" placeholder="请输入组织代码" @focus="selectOrganization()"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="组织名称" prop="fdOrganizationName">
              <el-input v-model="form.fdOrganizationName" placeholder="请输入组织名称" @focus="selectOrganization()"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="组织层级" prop="fdOrganizationLevel">
              <el-input v-model="form.fdOrganizationLevel" placeholder="请输入组织层级" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料名称" prop="fdItemName">
              <el-input v-model="form.fdItemName" placeholder="请输入物料名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料编号" prop="fdItemCode">
              <el-input v-model="form.fdItemCode" placeholder="请输入物料编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料子编号" prop="fdWlzbh">
              <el-input v-model="form.fdWlzbh" placeholder="请输入物料子编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料识别码" prop="fdItemIdentifyCode">
              <el-input v-model="form.fdItemIdentifyCode" placeholder="请输入物料识别码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料单位" prop="fdUnit">
              <el-input v-model="form.fdUnit" placeholder="请输入物料单位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="规格型号" prop="fdSpec">
              <el-input v-model="form.fdSpec" placeholder="请输入规格型号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="条码号" prop="fdBarcode">
              <el-input v-model="form.fdBarcode" placeholder="请输入条码号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料分类编码" prop="fdClassId">
              <el-input v-model="form.fdClassId" placeholder="请输入物料分类编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料分类名称" prop="fdClassName">
              <el-input v-model="form.fdClassName" placeholder="请输入物料分类名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料大类编码" prop="fdClassBigId">
              <el-input v-model="form.fdClassBigId" placeholder="请输入物料大类编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料大类名称" prop="fdClassBigName">
              <el-input v-model="form.fdClassBigName" placeholder="请输入物料大类名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商编码" prop="fdSupplyId">
              <el-input v-model="form.fdSupplyId" placeholder="请输入供应商编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商名称" prop="fdSupplyName">
              <el-input v-model="form.fdSupplyName" placeholder="请输入供应商名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商简称" prop="fdSupplyJc">
              <el-input v-model="form.fdSupplyJc" placeholder="请输入供应商简称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="存储期" prop="fdCunchudate">
              <el-input v-model="form.fdCunchudate" placeholder="请输入存储期" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="保质期" prop="fdProductiondate">
              <el-input v-model="form.fdProductiondate" placeholder="请输入保质期" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="图片地址" prop="fdUrl">
              <image-upload v-model="form.fdUrl"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="预警上线" prop="fdUpLine">
              <el-input v-model="form.fdUpLine" placeholder="请输入预警上线" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="预警下线" prop="fdDownLine">
              <el-input v-model="form.fdDownLine" placeholder="请输入预警下线" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="中间值" prop="fdMiddleLine">
              <el-input v-model="form.fdMiddleLine" placeholder="请输入中间值" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="尺寸" prop="fdSize">
              <el-input v-model="form.fdSize" placeholder="请输入尺寸" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单重" prop="fdSingleWeight">
              <el-input v-model="form.fdSingleWeight" placeholder="请输入单重" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="使用状态" prop="fdUseState">
              <el-input v-model="form.fdUseState" placeholder="请输入使用状态" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="颜色" prop="fdColor">
              <el-input v-model="form.fdColor" placeholder="请输入颜色" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="花纹" prop="fdFigure">
              <el-input v-model="form.fdFigure" placeholder="请输入花纹" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="材质" prop="fdCaizhi">
              <el-input v-model="form.fdCaizhi" placeholder="请输入材质" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="包装数量" prop="fdPackingNum">
              <el-input v-model="form.fdPackingNum" placeholder="请输入包装数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料状态" prop="fdItemState">
              <el-input v-model="form.fdItemState" placeholder="请输入物料状态" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="组织机构" prop="fdDeptId">
              <el-input v-model="form.fdDeptId" placeholder="请输入组织机构" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="托管状态" prop="fdTgState">
              <el-input v-model="form.fdTgState" placeholder="请输入托管状态" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="成本价" prop="fdCostPrice">
              <el-input v-model="form.fdCostPrice" placeholder="请输入成本价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划价" prop="fdJhPrice">
              <el-input v-model="form.fdJhPrice" placeholder="请输入计划价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合同价" prop="fdHtPrice">
              <el-input v-model="form.fdHtPrice" placeholder="请输入合同价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发票价" prop="fdFpPrice">
              <el-input v-model="form.fdFpPrice" placeholder="请输入发票价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结算价" prop="fdJsPrice">
              <el-input v-model="form.fdJsPrice" placeholder="请输入结算价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="生产周期" prop="fdProductionCycle">
              <el-input v-model="form.fdProductionCycle" placeholder="请输入生产周期" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供货周期" prop="fdSupplyCycle">
              <el-input v-model="form.fdSupplyCycle" placeholder="请输入供货周期" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供货份额" prop="fdDeliveryFe">
              <el-input v-model="form.fdDeliveryFe" placeholder="请输入供货份额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="份额调整比例" prop="fdAdjustRate">
              <el-input v-model="form.fdAdjustRate" placeholder="请输入份额调整比例" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="份额调整日期" prop="fdAdjustDate">
              <el-date-picker clearable
                v-model="form.fdAdjustDate"
                type="date"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择份额调整日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="月订单数量" prop="fdYddNum">
              <el-input v-model="form.fdYddNum" placeholder="请输入月订单数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="月完成数量" prop="fdYwcNum">
              <el-input v-model="form.fdYwcNum" placeholder="请输入月完成数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="月度供货未完成比率" prop="fdYghwcbl">
              <el-input v-model="form.fdYghwcbl" placeholder="请输入月度供货未完成比率" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="fdRemark">
              <el-input v-model="form.fdRemark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
          ref="upload"
          :limit="1"
          accept=".xlsx, .xls"
          :headers="upload.headers"
          :action="upload.url + '?updateSupport=' + upload.updateSupport"
          :disabled="upload.isUploading"
          :on-progress="handleFileUploadProgress"
          :on-success="handleFileSuccess"
          :auto-upload="false"
          drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <organizationalSelect ref="organizationalSelect" @onSelected="onSelected"></organizationalSelect>

  </div>
</template>

<script>
import { listIteminfo, getIteminfo, delIteminfo, addIteminfo, updateIteminfo } from "@/api/ys/iteminfo";
import {getToken} from "@/utils/auth";
export default {
  name: "Iteminfo",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 物料信息表格数据
      iteminfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        fdItemName: null,
        fdItemCode: null,
        fdWlzbh: null,
        fdItemIdentifyCode: null,
        fdSpec: null,
        fdClassId: null,
        fdClassName: null,
        fdClassBigId: null,
        fdClassBigName: null,
        fdSupplyId: null,
        fdSupplyName: null,
      },
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "导入`iteminfo`信息",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/ys/iteminfo/importData"
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /*选择组织*/
    selectOrganization() {
      this.$refs['organizationalSelect'].show()
    },
    /*选择组织组件回调*/
    /*参数：组织信息*/
    onSelected(org) {
      this.form.fdOrganizationCode=org.gcdm
      this.form.fdOrganizationName=org.gcmc
    },
    /** 查询物料信息列表 */
    getList() {
      this.loading = true;
      listIteminfo(this.queryParams).then(response => {
        this.iteminfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        fdSerialNum: null,
        fdOrganizationCode: null,
        fdOrganizationName: null,
        fdOrganizationCategory: null,
        fdOrganizationLevel: null,
        fdItemName: null,
        fdItemCode: null,
        fdWlzbh: null,
        fdItemIdentifyCode: null,
        fdUnit: null,
        fdSpec: null,
        fdBarcode: null,
        fdClassId: null,
        fdClassName: null,
        fdClassBigId: null,
        fdClassBigName: null,
        fdSupplyId: null,
        fdSupplyName: null,
        fdSupplyType: null,
        fdSupplyJc: null,
        fdCunchudate: null,
        fdProductiondate: null,
        fdUrl: null,
        fdUpLine: null,
        fdDownLine: null,
        fdMiddleLine: null,
        fdSize: null,
        fdSingleWeight: null,
        fdUseState: null,
        fdColor: null,
        fdFigure: null,
        fdCaizhi: null,
        fdPackingNum: null,
        fdBaozhuangType: null,
        fdItemState: null,
        fdDeptId: null,
        fdTgState: null,
        fdCostPrice: null,
        fdJhPrice: null,
        fdHtPrice: null,
        fdFpPrice: null,
        fdJsPrice: null,
        fdProductionCycle: null,
        fdSupplyCycle: null,
        fdDeliveryFe: null,
        fdAdjustRate: null,
        fdAdjustDate: null,
        fdYddNum: null,
        fdYwcNum: null,
        fdYghwcbl: null,
        fdRemark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加物料信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getIteminfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改物料信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateIteminfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addIteminfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除数据？').then(function() {
        return delIteminfo(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('ys/iteminfo/export', {
        ...this.queryParams
      }, `iteminfo_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "物料信息导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('ys/iteminfo/importTemplate', {
      }, `物料信息模板.xlsx`)
    },
    /** 文件上传中处理 */
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    /** 文件上传成功处理 */
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    /** 提交上传文件 */
    submitFileForm() {
      this.$refs.upload.submit();
    },
  }
};
</script>
